drop table qna_reply;

create table qna_reply(
	qa_re_no number primary key,
	qa_re_ref number,
	qa_re_bno number not null,
	qa_re_content varchar2(1000) not null,
	qa_re_writedate date not null,
	qa_re_restep number not null,
	qa_re_relevel number not null,
	qa_re_id varchar2(50) not null
)

  ALTER TABLE discussion_reply DROP CONSTRAINT fk_dis_re_ref;
ALTER TABLE discussion_reply ADD CONSTRAINT fk_dis_re_ref FOREIGN KEY (dis_re_ref) 
   REFERENCES discussion_board(dis_no) ON DELETE CASCADE
   
ALTER TABLE discussion_reply DROP CONSTRAINT fk_dis_re_id;
ALTER TABLE discussion_reply ADD CONSTRAINT fk_dis_re_id FOREIGN KEY (dis_re_id) 
   REFERENCES javabox_member(id) ON DELETE CASCADE

create sequence qna_reply_seq;

drop sequence qna_reply_seq;

insert into qna_reply values(qna_reply_seq.nextval,104,'홍홍홍홍',sysdate,0,0,'java');

select * from QNA_REPLY where qa_re_bno=21 order by qa_re_ref,qa_re_restep,qa_re_relevel desc;

select * from qna_reply;

select count(*) from qna_reply,discussion_reply where qa_re_id='java'

select qa_re_restep from (select qa_re_restep,CEIL(rownum/1) as num from (select qa_re_restep,CEIL(rownum/1) as num from qna_reply where qa_re_ref=125 order by num desc) order by num desc) where num=1

insert into qna_reply values(qna_reply_seq.nextval,#{ref},#{boardVO.no},#{rcontent},sysdate,#{restep},#{relevel},#{memberVO.id})


---------------------------------------------------------------------------------------

delete from qna_reply where dis_re_ref='2013-12-24'

create sequence dis_reply_seq;
drop sequence dis_reply_seq;

drop table discussion_reply;

create table discussion_reply (
	dis_re_no number primary key,
	dis_re_ref varchar2(50) not null,
	dis_re_id varchar2(50) not null,
	dis_re_content varchar2(1000) not null,
	constraint fk_dis_re_ref foreign key(dis_re_ref) references discussion_board(dis_no),
	constraint fk_dis_re_id foreign key(dis_re_id) references javabox_member(id)
)

insert into discussion_reply values(dis_reply_seq.nextval,'2013-12-10','java','test중...')

select * from DISCUSSION_REPLY order by dis_re_no asc;
select * from DISCUSSION_REPLY where dis_re_ref='2013-12-12';

update DISCUSSION_REPLY set dis_re_content='111111' where dis_re_no='30'